#pragma once

#include "umc_data_reader.h"

using namespace UMC;

class H264FrameReader : public DataReader
{
	DYNAMIC_CAST_DECL(H264FrameReader, DataReader); /*lint !e1511*/

public:
	H264FrameReader(void);
	~H264FrameReader(void);

	/// Initialization abstract source data
	virtual Status Init(DataReaderParams * /*InitParams*/) { return UMC_OK;}

	/// Close source data
	virtual Status Close(void) { return UMC_OK;}

	/// Reset all internal parameters to start reading from begin
	virtual Status Reset(void) { return UMC_OK;}

	/**
	Read nsize bytes and copy to data (return number bytes which was copy).
	Cache data in case of small nsize
	*/
	virtual Status ReadData(void *data, Ipp32u *nsize);
	/// Move position on npos bytes
	virtual Status MovePosition(Ipp64u /*npos*/) { return UMC_OK;}

	/// Cache and check data
	virtual Status CacheData(void * /*data*/, Ipp32u * /*nsize*/, Ipp32s /*how_far*/) { return UMC_OK;}

	/// Obtain position in the stream
	virtual Ipp64u GetPosition(void);
	/// Obtain size in source data
	virtual Ipp64u GetSize(void) { return 0xFFFFFFFFFFFFFFFFULL;}
	/// Set new position
	virtual Status SetPosition(Ipp64f /*pos*/) { return UMC_OK;}

	/// Set new position
	virtual Status SetPosition (Ipp64u pos)
	{
		Ipp64u curr_pos = GetPosition();
		if (pos >= curr_pos)
		{
			return MovePosition((pos-curr_pos));
		}
		else
		{
			SetPosition(0.0);

			return MovePosition(pos);
		}
	}

	void PutData(Ipp8u *data, Ipp32u dataLen);
	Ipp32u GetRemainDataSize();

private:
	Ipp64u m_streamPosition;
};